<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <meta http-equiv="X-UA-Compatible" content="ie=edge" />
    <title>v-for加:key</title>
    <script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
  </head>

  <body>
    <!-- 官方推荐我们在使用v-for时，给对应的元素或组件添加上一个:key属性。 -->
    <!--  key的作用主要是为了高效的更新虚拟DOM。-->
    <div id="app">
      <ul>
        <li v-for="item in letter" :key="item">{{item}}</li>
      </ul>
    </div>
    <script>
      //创建Vue实例,得到 ViewModel
      var app = new Vue({
        el: "#app",
        data: {
          letter: ["A", "B", "C", "D", "E"],
        },
        methods: {},
      });
    </script>
  </body>
</html>
